package cn.yunhe.controll;

import java.util.List;

import cn.yunhe.model.House;
import cn.yunhe.services.SerRent;
import cn.yunhe.until.PageUtil;


public class GetHouseByKeywordsAction extends BaseAction {
	private String pageIndex;
	private String title;
	private String street;
	private String type;
	private String floorage;
	private String price;
	private int currPage;
	private List<House> house;
	private int totalPage;

	SerRent serRent = new SerRent();
	public String getHouseByKeywords() {
		System.out.println(pageIndex+","+title+","+street+","+type+","+floorage+","+price);
		
		if (pageIndex != null && !"".equals(pageIndex)) {
			currPage = Integer.parseInt(pageIndex);
		}
		/*int sId=userService.getS_idByS_name(street);
		String s_id=String.valueOf(sId); 
		int tId=userService.getT_idByT_name(type);
		String t_id=String.valueOf(tId);*/
		int getCount = serRent.getHouseCountByKeywords(title, street, type, floorage, price, currPage);
		totalPage = PageUtil.pageCount(3, getCount);
		// 处理首尾页
		if (currPage < 1) {
			currPage = 1;
		} else if (currPage > totalPage) {
			currPage = totalPage;
		}
		house = serRent.getHouseByKeyword(title, street, type, floorage, price, currPage);
		return "success";
	}

	public String getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(String pageIndex) {
		this.pageIndex = pageIndex;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getFloorage() {
		return floorage;
	}

	public void setFloorage(String floorage) {
		this.floorage = floorage;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public int getCurrPage() {
		return currPage;
	}

	public void setCurrPage(int currPage) {
		this.currPage = currPage;
	}

	public List<House> getHouse() {
		return house;
	}

	public void setHouse(List<House> house) {
		this.house = house;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

}
